<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>博客</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.css">
    <!--th是thymeleaf模板所需要加载的东西-->
    <link rel="stylesheet" href="../static/css/me.css" th:href="@{/css/me.css}">
</head>
<body>


<!--导航的部分--><!--有线程的组件-->
<nav class="ui inverted vertical attach segment m-padded-tb-mini m-shadow-small">
    <div class="ui container">
        <!--左边的导航-->
        <div class="ui secondary inverted stackable menu">
            <h2 class="ui header teal item">Timous</h2>
            <a href="#" th:href="@{/}" class="m-item item m-mobile-hide active"><i class="mini home icon"></i>首页</a>
            <a href="#" th:href="@{/types/-1}" class="m-item item m-mobile-hide"><i class="mini idea icon"></i>分类</a>
            <a href="#" th:href="@{/tags/-1}" class="m-item item m-mobile-hide"><i class="mini tags icon"></i>标签</a>
            <a href="#" th:href="@{/archives}" class="m-item item m-mobile-hide"><i class="mini clone icon"></i>归档</a>
            <a href="#" th:href="@{/blogabout}"   class="m-item item m-mobile-hide"><i class="mini info icon"></i>关于我</a>
            <a href="#" th:href="@{/types/-1}"   class="m-item item m-mobile-hide"><i class="mini music icon"></i>音乐盒</a>
            <a href="#" th:href="@{/types/-1}"  class="m-item item m-mobile-hide"><i class="mini user icon"></i>友人帐</a>
            <a href="#" th:classappend="${num==8} ? 'active'" class="m-item item m-mobile-hide"><i class="mini photo icon"></i>照片墙</a>
            <div class="m-item right item m-mobile-hide">
                <div class="ui icon inverted transparent input">
                    <input type="text" placeholder="Search...">
                    <i class="search link icon"></i>
                </div>
            </div>
        </div>


        <!--        加一个隐藏的图标-->
        <a href="#" class="ui menu toggle black icon button m-top-right m-mobile-show">
            <i class="sidebar icon"></i>
        </a>
    </div>


</nav>

<!--中间的内容-->
<div class="m-padded-tb-massive m-container">
    <div class="ui container">
        <div class="ui stackable grid">
            <div class="eleven wide column">

                <!--头部的 信息-->
                <div class="ui segment top attached">
                    <div class="ui middle aligned two column grid">
                        <div class="column">
                            <h3 class="ui teal header">博客</h3>
                        </div>
                        <div class="right aligned column">
                            共<h2 class="ui orange header m-inline-block m-text-thin" th:text="${page.totalElements}">
                            14</h2>篇博客
                        </div>
                    </div>
                </div>


                <!--博客的容器-->
                <div class="ui attached segment" style="margin-right: 20px !important;">

                    <!--博客的内容-->
                    <div class="ui padded vertical segment m-padded-tb-huge" th:each="blog : ${page.content}">

                        <div class="ui middle aligned mobile reversed stackable  grid">

                            <!--首页展示的博客的具体的内容-->
                            <div class="ui eleven wide column">
                                <!--博客的标题-->

                                <h3 class="ui header">
                                    <a href="#" target="_blank" th:href="@{/blog/{id}(id=${blog.id})}" class="m-black"
                                       th:text="|${blog.title}....|">你真的理解什么是财富自由吗？</a>
                                </h3>

                                <!--博客里面的内容-->
                                <p class="m-text" th:text="${blog.description}">Lorem ipsum dolor sit amet, consectetur
                                    adipisicing elit. Debitis eaque exercitationem quibusdam. Aliquam animi culpa dicta
                                    eius excepturi exercitationem facere, ipsa laudantium natus non nostrum odit quaerat
                                    quia quidem, tempore!</p>

                                <div class="ui grid">
                                    <!--左边的下面的内容-->
                                    <div class="eleven wide column">

                                        <div class="ui link mini list horizontal">
                                            <div class="item">
                                                <img src="https://picsum.photos/id/1005/100/100"
                                                     th:src="@{${blog.user.avatar}}" alt="" class="ui avatar image">
                                                <div class="content">

                                                    <a href="#" class="header" th:text="${blog.user.nickname}">陈留红</a>

                                                </div>
                                            </div>

                                            <div class="item">

                                                <i class="icon calendar"></i><span
                                                    th:text="${#dates.format(blog.updateTime,'yyyy-MM-dd')}">2017-10-1</span>

                                            </div>

                                            <div class="item">

                                                <i class="icon eye"></i><span th:text="${blog.views}">12</span>

                                            </div>

                                        </div>

                                    </div>
                                    <div class="five wide column right aligned ">
                                        <a href="#" class="ui label teal basic m-padded-mini m-text-thin"
                                           target="_blank" th:text="${blog.type.name}">认知升级</a>
                                    </div>

                                </div>
                            </div>

                            <!--博客的图片的部分-->
                            <div class="ui five wide column">

                                <a href="#" target="_blank" th:href="@{/blog/{id}(id=${blog.id})}">

                                    <img src="https://picsum.photos/id/1005/800/400" th:src="${blog.firstPicture}"
                                         alt="" class="ui rounded image">

                                </a>


                            </div>

                        </div>

                    </div>

                </div>


                <!--尾部的部分  分页-->
                <div class="ui bottom attached segment" th:if="${page.totalPages}>1">
                    <div class="ui middle aligned two column grid">
                        <div class="column">
                            <a href="#" th:href="@{/(page=${page.number}-1)}" th:unless="${page.first}"
                               class="ui button teal basic m-padded-tb-large">上一页</a>
                        </div>
                        <div class="right aligned column">
                            <a href="" th:href="@{/(page=${page.number}+1)}" th:unless="${page.last}"
                               class="ui button teal basic m-padded-tb-large">下一页</a>
                        </div>
                    </div>

                </div>
            </div>
            <!--右边的部分-->
            <div class="five wide column">

                <canvas class="m-mobile-hide" id="myCanvas"
                        style="width:295.75px;background:#fff;border:1px solid #ccc;padding:10px;" height="100"
                        width="700">
                    当前浏览器不支持canvas，请更换浏览器后再试
                </canvas>


                <!--分类的部分-->
                <div class="ui segments">
                    <div class="ui secondary segment ">

                        <!--这是上面的导航的部分-->
                        <div class="ui two column grid">
                            <div class="column">
                                <i class="idea icon"></i>
                                分类
                            </div>
                            <div class="right aligned column">
                                <a href="#" th:href="@{/types/-1}" target="_blank">more <i class="icon angle double right"></i></a>
                            </div>
                        </div>
                    </div>

                    <div class="ui teal segment">

                        <div class="ui fluid vertical menu">
                            <a class="item" target="_blank" href="#" th:href="@{/types/{id}(id=${type.id})}" th:each="type : ${types}">
                                <span th:text="${type.name}">学习日志</span>
                                <div class="ui teal basic left pointing label" th:text="${#arrays.length(type.blogs)}">
                                    13
                                </div>
                            </a>
                        </div>

                    </div>

                </div>


                <!--标签的部分-->
                <div class="ui segments m-margin-tb-large">
                    <div class="ui secondary segment">

                        <!--这是上面的导航的部分-->
                        <div class="ui two column grid">
                            <div class="column">
                                <i class="tags icon"></i>
                                标签
                            </div>
                            <div class="right aligned column">
                                <a href="#" th:href="@{/tags/-1}" target="_blank">more <i class="icon angle double right"></i></a>
                            </div>
                        </div>
                    </div>

                    <!--下面的标签的具体的部分-->

                    <div class="ui teal segment">
                        <a class="item ui teal basic left pointing label m-margin-tb-mini" th:href="@{/tags/{id}(id=${tag.id})}" href="#"
                           th:each="tag : ${tags}">
                            <span th:text="${tag.name}">方法论</span>
                            <div class="detail" th:text="${#arrays.length(tag.blogs)}">23</div>
                        </a>
                    </div>
                </div>


                <!--最新推荐-->
                <div class="ui segments m-margin-tb-large">

                    <div class="ui secondary segment">
                        <i class="bookmark icon"></i>最新推荐
                    </div>
                    <div class="ui segment" th:each="blog : ${recommendBlogs}">
                        <a href="#" target="_blank" th:href="@{/blog/{id}(id=${blog.id})}" class="m-black m-text-thin"
                           th:text="${blog.title}">用户故事（User Story）</a>
                    </div>
                </div>
                <!--二维码-->

                <h4 class="ui horizontal divider header m-margin-tb-large">扫码关注我</h4>
                <div class="ui centered card" style="width:11em;">
                    <img src="../static/images/wechat.png" th:src="@{/images/wechat.png}" alt=""
                         class="ui rounded image">
                </div>


            </div>
        </div>
    </div>

</div>


<!--底部的内容-->
<!--底部的内容-->
<footer  class="ui segment inverted vertical me-padded-td-mini">
    <div class=" m-padded-tb-massive ui center aligned container">
        <!--grid会把整个页面分成16分-->
        <div class="ui divided  inverted stackable grid ">
            <div class="three wide column">
                <div class="ui inverted link list">
                    <div class="item">
                        <img src="../static/images/wechat.png" th:src="@{/images/wechat.png}" class="ui rounded image"
                             alt="" style="width:110px;">
                    </div>
                </div>
            </div>
            <div class="three wide column">
                <div class="ui inverted link list">
                    <div class="item">
                        <img src="../static/images/wechat.png" th:src="@{/images/wechat.png}" class="ui rounded image"
                             alt="" style="width:110px;">
                    </div>
                </div>
            </div>
            <div class="three wide column">
                <h4 class="ui inverted header m-text-space m-opacity-mini">联系我</h4>
                <div class="ui inverted link list">
                    <a href="#" class="item m-text-thin m-text-space m-opacity-mini" th:text="#{index.email}">Email：1844736251@qq.com</a>
                    <a href="#" class="item m-text-thin m-text-space m-opacity-mini" th:text="#{index.QQ}">QQ:1844736251</a>
                </div>
            </div>
            <div class="seven wide column">
                <h4 class="ui inverted header m-text-thin m-text-space m-opacity-mini">本网站营业时间</h4>
                <div id="time"></div>
            </div>
        </div>
        <div class="ui inverted section divider"></div>
        <p class="m-text-thin m-text-space m-opacity-mini">Copyright © 2020-2021 Timous Designed By 陈留红</p>
    </div>
</footer>

<!-- 引入Jquery-->
<script src="https://cdn.jsdelivr.net/npm/jquery@3.2/dist/jquery.min.js"></script>
<!-- 引入组件库 -->
<script src="https://cdn.jsdelivr.net/semantic-ui/2.2.4/semantic.min.js"></script>
<script src="../static/js/me.js" th:src="@{/js/me.js}"></script>
<script>

    // 运行时间统计
    function secondToDate(second) {
        if (!second) {
            return 0;
        }
        var time = new Array(0, 0, 0, 0, 0);
        if (second >= 365 * 24 * 3600) {
            time[0] = parseInt(second / (365 * 24 * 3600));
            second %= 365 * 24 * 3600;
        }
        if (second >= 24 * 3600) {
            time[1] = parseInt(second / (24 * 3600));
            second %= 24 * 3600;
        }
        if (second >= 3600) {
            time[2] = parseInt(second / 3600);
            second %= 3600;
        }
        if (second >= 60) {
            time[3] = parseInt(second / 60);
            second %= 60;
        }
        if (second > 0) {
            time[4] = second;
        }
        return time;
    }

    function setTime() {
        /*此处为网站的创建时间*/
        var create_time = Math.round(new Date(Date.UTC(2020, 1, 25, 15, 15, 15)).getTime() / 1000);
        var timestamp = Math.round((new Date().getTime() + 8 * 60 * 60 * 1000) / 1000);
        currentTime = secondToDate((timestamp - create_time));
        currentTimeHtml = currentTime[0] + '年' + currentTime[1] + '天'
            + currentTime[2] + '时' + currentTime[3] + '分' + currentTime[4]
            + '秒';
        document.getElementById("time").innerHTML = currentTimeHtml;
    }

    setInterval(setTime, 1000);
</script>

<script type="text/javascript">
    (function () {

        var digit =
            [
                [
                    [0, 0, 1, 1, 1, 0, 0],
                    [0, 1, 1, 0, 1, 1, 0],
                    [1, 1, 0, 0, 0, 1, 1],
                    [1, 1, 0, 0, 0, 1, 1],
                    [1, 1, 0, 0, 0, 1, 1],
                    [1, 1, 0, 0, 0, 1, 1],
                    [1, 1, 0, 0, 0, 1, 1],
                    [1, 1, 0, 0, 0, 1, 1],
                    [0, 1, 1, 0, 1, 1, 0],
                    [0, 0, 1, 1, 1, 0, 0]
                ],//0
                [
                    [0, 0, 0, 1, 1, 0, 0],
                    [0, 1, 1, 1, 1, 0, 0],
                    [0, 0, 0, 1, 1, 0, 0],
                    [0, 0, 0, 1, 1, 0, 0],
                    [0, 0, 0, 1, 1, 0, 0],
                    [0, 0, 0, 1, 1, 0, 0],
                    [0, 0, 0, 1, 1, 0, 0],
                    [0, 0, 0, 1, 1, 0, 0],
                    [0, 0, 0, 1, 1, 0, 0],
                    [1, 1, 1, 1, 1, 1, 1]
                ],//1
                [
                    [0, 1, 1, 1, 1, 1, 0],
                    [1, 1, 0, 0, 0, 1, 1],
                    [0, 0, 0, 0, 0, 1, 1],
                    [0, 0, 0, 0, 1, 1, 0],
                    [0, 0, 0, 1, 1, 0, 0],
                    [0, 0, 1, 1, 0, 0, 0],
                    [0, 1, 1, 0, 0, 0, 0],
                    [1, 1, 0, 0, 0, 0, 0],
                    [1, 1, 0, 0, 0, 1, 1],
                    [1, 1, 1, 1, 1, 1, 1]
                ],//2
                [
                    [1, 1, 1, 1, 1, 1, 1],
                    [0, 0, 0, 0, 0, 1, 1],
                    [0, 0, 0, 0, 1, 1, 0],
                    [0, 0, 0, 1, 1, 0, 0],
                    [0, 0, 1, 1, 1, 0, 0],
                    [0, 0, 0, 0, 1, 1, 0],
                    [0, 0, 0, 0, 0, 1, 1],
                    [0, 0, 0, 0, 0, 1, 1],
                    [1, 1, 0, 0, 0, 1, 1],
                    [0, 1, 1, 1, 1, 1, 0]
                ],//3
                [
                    [0, 0, 0, 0, 1, 1, 0],
                    [0, 0, 0, 1, 1, 1, 0],
                    [0, 0, 1, 1, 1, 1, 0],
                    [0, 1, 1, 0, 1, 1, 0],
                    [1, 1, 0, 0, 1, 1, 0],
                    [1, 1, 1, 1, 1, 1, 1],
                    [0, 0, 0, 0, 1, 1, 0],
                    [0, 0, 0, 0, 1, 1, 0],
                    [0, 0, 0, 0, 1, 1, 0],
                    [0, 0, 0, 1, 1, 1, 1]
                ],//4
                [
                    [1, 1, 1, 1, 1, 1, 1],
                    [1, 1, 0, 0, 0, 0, 0],
                    [1, 1, 0, 0, 0, 0, 0],
                    [1, 1, 1, 1, 1, 1, 0],
                    [0, 0, 0, 0, 0, 1, 1],
                    [0, 0, 0, 0, 0, 1, 1],
                    [0, 0, 0, 0, 0, 1, 1],
                    [0, 0, 0, 0, 0, 1, 1],
                    [1, 1, 0, 0, 0, 1, 1],
                    [0, 1, 1, 1, 1, 1, 0]
                ],//5
                [
                    [0, 0, 0, 0, 1, 1, 0],
                    [0, 0, 1, 1, 0, 0, 0],
                    [0, 1, 1, 0, 0, 0, 0],
                    [1, 1, 0, 0, 0, 0, 0],
                    [1, 1, 0, 1, 1, 1, 0],
                    [1, 1, 0, 0, 0, 1, 1],
                    [1, 1, 0, 0, 0, 1, 1],
                    [1, 1, 0, 0, 0, 1, 1],
                    [1, 1, 0, 0, 0, 1, 1],
                    [0, 1, 1, 1, 1, 1, 0]
                ],//6
                [
                    [1, 1, 1, 1, 1, 1, 1],
                    [1, 1, 0, 0, 0, 1, 1],
                    [0, 0, 0, 0, 1, 1, 0],
                    [0, 0, 0, 0, 1, 1, 0],
                    [0, 0, 0, 1, 1, 0, 0],
                    [0, 0, 0, 1, 1, 0, 0],
                    [0, 0, 1, 1, 0, 0, 0],
                    [0, 0, 1, 1, 0, 0, 0],
                    [0, 0, 1, 1, 0, 0, 0],
                    [0, 0, 1, 1, 0, 0, 0]
                ],//7
                [
                    [0, 1, 1, 1, 1, 1, 0],
                    [1, 1, 0, 0, 0, 1, 1],
                    [1, 1, 0, 0, 0, 1, 1],
                    [1, 1, 0, 0, 0, 1, 1],
                    [0, 1, 1, 1, 1, 1, 0],
                    [1, 1, 0, 0, 0, 1, 1],
                    [1, 1, 0, 0, 0, 1, 1],
                    [1, 1, 0, 0, 0, 1, 1],
                    [1, 1, 0, 0, 0, 1, 1],
                    [0, 1, 1, 1, 1, 1, 0]
                ],//8
                [
                    [0, 1, 1, 1, 1, 1, 0],
                    [1, 1, 0, 0, 0, 1, 1],
                    [1, 1, 0, 0, 0, 1, 1],
                    [1, 1, 0, 0, 0, 1, 1],
                    [0, 1, 1, 1, 0, 1, 1],
                    [0, 0, 0, 0, 0, 1, 1],
                    [0, 0, 0, 0, 0, 1, 1],
                    [0, 0, 0, 0, 1, 1, 0],
                    [0, 0, 0, 1, 1, 0, 0],
                    [0, 1, 1, 0, 0, 0, 0]
                ],//9
                [
                    [0, 0, 0, 0, 0, 0, 0],
                    [0, 0, 1, 1, 1, 0, 0],
                    [0, 0, 1, 1, 1, 0, 0],
                    [0, 0, 1, 1, 1, 0, 0],
                    [0, 0, 0, 0, 0, 0, 0],
                    [0, 0, 0, 0, 0, 0, 0],
                    [0, 0, 1, 1, 1, 0, 0],
                    [0, 0, 1, 1, 1, 0, 0],
                    [0, 0, 1, 1, 1, 0, 0],
                    [0, 0, 0, 0, 0, 0, 0]
                ]//:
            ];

        var canvas = document.getElementById('myCanvas');
        //声明canvas的宽高
        var H = 100, W = 700;
        canvas.height = H;
        canvas.width = W;
        if (canvas.getContext) {
            var cxt = canvas.getContext('2d');
        }
        cxt.fillStyle = '#f00';
        cxt.fillRect(10, 10, 50, 50);


        //存储时间数据
        var data = [];
        //存储运动的小球
        var balls = [];
        //设置粒子半径
        var R = canvas.height / 20 - 1;
        (function () {
            var temp = /(\d)(\d):(\d)(\d):(\d)(\d)/.exec(new Date());
            //存储时间数字，由十位小时、个位小时、冒号、十位分钟、个位分钟、冒号、十位秒钟、个位秒钟这7个数字组成
            data.push(temp[1], temp[2], 10, temp[3], temp[4], 10, temp[5], temp[6]);
        })();

        /*生成点阵数字*/
        function renderDigit(index, num) {
            for (var i = 0; i < digit[num].length; i++) {
                for (var j = 0; j < digit[num][i].length; j++) {
                    if (digit[num][i][j] == 1) {
                        cxt.beginPath();
                        cxt.arc(14 * (R + 2) * index + j * 2 * (R + 1) + (R + 1), i * 2 * (R + 1) + (R + 1), R, 0, 2 * Math.PI);
                        cxt.closePath();
                        cxt.fill();
                    }
                }
            }
        }

        /*更新时钟*/
        function updateDigitTime() {
            var changeNumArray = [];
            var temp = /(\d)(\d):(\d)(\d):(\d)(\d)/.exec(new Date());
            var NewData = [];
            NewData.push(temp[1], temp[2], 10, temp[3], temp[4], 10, temp[5], temp[6]);
            for (var i = data.length - 1; i >= 0; i--) {
                //时间发生变化
                if (NewData[i] !== data[i]) {
                    //将变化的数字值和在data数组中的索引存储在changeNumArray数组中
                    changeNumArray.push(i + '_' + (Number(data[i]) + 1) % 10);
                }
            }
            //增加小球
            for (var i = 0; i < changeNumArray.length; i++) {
                addBalls.apply(this, changeNumArray[i].split('_'));
            }
            data = NewData.concat();
        }

        /*更新小球状态*/
        function updateBalls() {
            for (var i = 0; i < balls.length; i++) {
                balls[i].stepY += balls[i].disY;
                balls[i].x += balls[i].stepX;
                balls[i].y += balls[i].stepY;
                if (balls[i].x > W + R || balls[i].y > H + R) {
                    balls.splice(i, 1);
                    i--;
                }
            }
        }

        /*增加要运动的小球*/
        function addBalls(index, num) {
            var numArray = [1, 2, 3];
            var colorArray = ["#3BE", "#09C", "#A6C", "#93C", "#9C0", "#690", "#FB3", "#F80", "#F44", "#C00"];
            for (var i = 0; i < digit[num].length; i++) {
                for (var j = 0; j < digit[num][i].length; j++) {
                    if (digit[num][i][j] == 1) {
                        var ball = {
                            x: 14 * (R + 2) * index + j * 2 * (R + 1) + (R + 1),
                            y: i * 2 * (R + 1) + (R + 1),
                            stepX: Math.floor(Math.random() * 4 - 2),
                            stepY: -2 * numArray[Math.floor(Math.random() * numArray.length)],
                            color: colorArray[Math.floor(Math.random() * colorArray.length)],
                            disY: 1
                        };
                        balls.push(ball);
                    }
                }
            }
        }

        /*渲染*/
        function render() {
            //重置画布宽度，达到清空画布的效果
            canvas.height = 100;
            //渲染时钟
            for (var i = 0; i < data.length; i++) {
                renderDigit(i, data[i]);
            }
            //渲染小球
            for (var i = 0; i < balls.length; i++) {
                cxt.beginPath();
                cxt.arc(balls[i].x, balls[i].y, R, 0, 2 * Math.PI);
                cxt.fillStyle = balls[i].color;
                cxt.closePath();
                cxt.fill();
            }
        }

        clearInterval(oTimer);
        var oTimer = setInterval(function () {
            //更新时钟
            updateDigitTime();
            //更新小球状态
            updateBalls();
            //渲染
            render();
        }, 50);

    })();

</script>

<script>


    // 运行时间统计
    function secondToDate(second) {
        if (!second) {
            return 0;
        }
        var time = new Array(0, 0, 0, 0, 0);
        if (second >= 365 * 24 * 3600) {
            time[0] = parseInt(second / (365 * 24 * 3600));
            second %= 365 * 24 * 3600;
        }
        if (second >= 24 * 3600) {
            time[1] = parseInt(second / (24 * 3600));
            second %= 24 * 3600;
        }
        if (second >= 3600) {
            time[2] = parseInt(second / 3600);
            second %= 3600;
        }
        if (second >= 60) {
            time[3] = parseInt(second / 60);
            second %= 60;
        }
        if (second > 0) {
            time[4] = second;
        }
        return time;
    }

    function setTime() {
        /*此处为网站的创建时间*/
        var create_time = Math.round(new Date(Date.UTC(2020, 1, 25, 15, 15, 15)).getTime() / 1000);
        var timestamp = Math.round((new Date().getTime() + 8 * 60 * 60 * 1000) / 1000);
        currentTime = secondToDate((timestamp - create_time));
        currentTimeHtml = currentTime[0] + '年' + currentTime[1] + '天'
            + currentTime[2] + '时' + currentTime[3] + '分' + currentTime[4]
            + '秒';
        document.getElementById("time").innerHTML = currentTimeHtml;
    }

    setInterval(setTime, 1000);


    $("#newblog-container").load(/*[[@{/footer/newblog}]]*/"/footer/newblog");

</script>
</body>
</html>